package com.company;

import com.company.service.MyCallableClass;
import com.company.service.MyRunnableClass;
import com.company.service.MyThreadClass;

import java.util.concurrent.FutureTask;

public class Task1 {
    public static void main(String[] args) {
        //todo 1.练习线程的几种创建方式
        Thread thread0 = new MyThreadClass();
        thread0.start();

        Runnable runnable = new MyRunnableClass();
        Thread thread1 = new Thread(runnable);
        thread1.start();

        try {
            MyCallableClass myCallable = new MyCallableClass();
            FutureTask<Object> futureTask = new FutureTask<>(myCallable);
            Thread thread2 = new Thread(futureTask);
            thread2.start();
            Object result = futureTask.get();
            System.out.println(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
